<h3>Danh sách khách hàng</h3>
<hr>

<form action="<?php echo base_url()?>index.php/customer/get_by_fillter" method="post">
<table>
	<tr>
		<td>Tên</td>
		<td>Tài khoản</td>
		<td>Điện thoại</td>
		<td>Tỉnh</td>
		<td>Quận</td>
		<td>Nhóm</td>
		<td>Trạng thái</td>
		
	</tr>
	<tr>
		<td><input type = 'text' name = 'name' /></td>
		<td><input type = 'text' name = 'username' /></td>
		<td><input type = 'text' name = 'phone' /></td>
		<td>
		<select name = 'province'>
			<option value = '0'>Tất cả</option>
				<?php foreach ($province as $item): ?>
					<option value = '<?php echo $item['province'];?>'><?php echo $item['province'];?></option>
				<?php endforeach;?>
		</select>
		</td>
		<td>
		<select name = 'district'>
			<option value = '0'>Tất cả</option>
				<?php foreach ($district as $item): ?>
					<option value = '<?php echo $item['district'];?>'><?php echo $item['district'];?></option>
				<?php endforeach;?>
		</select>
		</td>
		<td>
		<select name = 'group'>
			<option value = '0'>Tất cả</option>
			<option value = 'Online'>Online</option>
			<option value = 'Offline'>Offline</option>
		</select>
		</td>
		<td>
		<select name = 'status'>
			<option value = '0'>Tất cả</option>
			<option value = 'Kích hoạt'>Kích hoạt</option>
			<option value = 'Chưa kích hoạt'>Chưa kích hoạt</option>
		</select>
		</td>
		<td><input type = 'submit' name = 'search' value = 'Search'></td>
	</tr>
</table>
</form>

<script type="text/javascript">	
  	function doDelete() {		
  		answer = confirm("Bạn chắc chắn muốn xóa nhà cung cấp này?");		
  		if(answer) {			
  			document.getElementById('frm_delete').submit();		
  		}	
  	}
 </script> 
  
<div style="height: 38px; border-bottom: 1px solid grey; margin-bottom: 20px; padding-right: 30px; ">
	<a onclick = "doDelete()" href="#" style="float: right">
		<img src="<?php echo base_url()?>template/backend/images/btn_delete.png" border="0" />
	</a>
	<a href="<?php echo base_url()?>index.php/customer/add"  style="float: right; margin-right: 20px">
		<img src="<?php echo base_url()?>template/backend/images/btn_add.png" border="0" />
	</a>
	<div class="clear: right"></div>
</div>

<form action="<?php echo base_url().'index.php/customer/delete'?>" method="post" enctype="multipart/form-data" id="frm_delete">
<table class="list" width="100%" cellpadding="5">
	<tr style="color: #fff; font-weight: bold" bgcolor="#ad2f33" >
		<td align="center">
			<input type="checkbox" onclick="$('input[name*=\'selected\']').attr('checked', this.checked);" />
		</td>
		<td>Tên</td>
		<td>Địa chỉ</td>
		<td>Email/Điện thoại</td>
		<td>Trạng thái</td>
		<td>Nhóm</td>
		<td>Mô tả</td>
		<td>Hành động</td>
	</tr>
	<?php if ($customers) { ?>
    <?php $class = 'odd_row_style'; ?>
    <?php foreach ($customers as $customer) { ?>
    <?php $class = ($class == 'even_row_style' ? 'odd_row_style' : 'even_row_style'); ?>
      
      <tr class="<?php echo $class; ?>">
		<td align="center"><input type="checkbox" name="selected[]" value="<?php echo $customer['id']; ?>" /> </td>
    	<td align="center">
    		<a href="<?php echo base_url().'index.php/customer/view/'. $customer['id'] ;?>">
    			<img src="<?php echo base_url() . $customer['avatar']?>" style="display: block; margin: 3px" />
    		</a>
    		<a style="text-decoration: none;" href="<?php echo base_url().'index.php/customer/view/'. $customer['id'] ;?>">
    			<?php echo '<p>' . $customer['name'] . '</p>' ?>
    		</a>
    	</td>
    	
    	<td>
        	<?php echo '<p>' . $customer['address'] . '</p>';  ?>
        	<?php echo '<p>'. $customer['district'] . '</p>';  ?>
        	<?php echo '<p>'. $customer['province'] . '</p>';  ?>
        </td>
        
        <td>
        	<?php echo '<p>' . $customer['email'] . '</p>';  ?>
        	<?php echo '<p>'. $customer['phone'] . '</p>';  ?>
        </td>
        
        <td><?php echo $customer['active_status'] ?></td>
        
        <td><?php echo $customer['group'] ?></td>
        
        <td><?php echo $customer['description'] ?></td>
        
    	<td align="center">
    		<!--  a href="<?php echo base_url().'index.php/customer/'. $customer['id'] ;?>">Xem-->
    		<a href="<?php echo base_url().'index.php/customer/update/'.$customer['id']?>">Sửa</a>
    	</td>
    </tr>
    <?php } ?>
	<?php } ?>
	
</table>
</form>